<template>
	<div>
		<el-row :gutter="24">
			<el-col :span="3" style="margin-left:5px;">
				<el-input size="small" v-model="dictTreeSearchValue" placeholder="请输入内容" icon="search" @click="searchTree"></el-input>
			</el-col>
			<el-col :span="2" style="margin-right: 0px;">
				<el-select size="small" v-model="allSeries" placeholder="请选择" clearable>
					<el-option label="在售" value="1"></el-option>
					<el-option label="全部" value="0"></el-option>
				</el-select>
			</el-col>
			
				<el-col :span="1" style="margin-left:0px;">
					<el-button type="primary" size="small" v-on:click='queryParamTree()'>查询</el-button>
				</el-col>
				
			<el-col :span="18" style="margin-right: -5px;" v-if="carType=='0'">
				<el-col :span="1" style="">
					<p class="queryLabel">车系代码:</p>
				</el-col>
				<el-col :span="5" style="float: left;margin-left: 20px;">
					<el-input size="small" v-model="carModuleNoData" placeholder="输入车系代码" style="width:120!important"></el-input>
				</el-col>
				<el-col :span="1">
					<el-button type="primary" size="small" v-on:click='carSeriesQuery'>查询</el-button>
				</el-col>
				<el-col :span="8" style="text-align: right;margin:10px 0 4px -15px;float: right;">
					<el-button type="primary" size="small" v-on:click='carSeriesAdd' v-if="btnGroup.add">新增</el-button>
					<el-button type="primary" size="small" v-on:click='editCarSeries' v-if="btnGroup.edit">编辑</el-button>
					<el-button type="primary" size="small" v-on:click='startCarSeries' v-if="btnGroup.start">启用</el-button>
					<el-button type="primary" size="small" v-on:click='stopCarSeries' v-if="btnGroup.stop">停用</el-button>
				</el-col>
			</el-col>
			<el-col :span="18" style="margin-right: -5px;" v-if="carType=='1'">
				<el-col :span="1" style="">
					<p class="queryLabel">型号名称:</p>
				</el-col>
				<el-col :span="5" style="float: left;margin-left: 20px;">
					<el-input size="small" v-model="carModuleData" placeholder="输入车辆型号" style="width:120!important"></el-input>
				</el-col>
				<el-col :span="1">
					<el-button type="primary" size="small" v-on:click='carModelQuery'>查询</el-button>
				</el-col>
				<el-col :span="8" style="text-align: right;margin:10px 0 4px -15px;float: right;">
					<el-button type="primary" size="small" v-on:click='carModelAdd' v-if="btnGroup.add">新增</el-button>
					<el-button type="primary" size="small" v-on:click='editCarModel' v-if="btnGroup.edit">编辑</el-button>
					<el-button type="primary" size="small" v-on:click='startCarModel' v-if="btnGroup.start">启用</el-button>
					<el-button type="primary" size="small" v-on:click='stopCarModel' v-if="btnGroup.stop">停用</el-button>
				</el-col>
			</el-col>
			<el-col :span="18" style="margin-right: -5px;" v-if="carType=='2'">
				<el-col :span="1" style="">
					<p class="queryLabel">配置代码:</p>
				</el-col>
				<el-col :span="5" style="float: left;margin-left: 20px;">
					<el-input size="small" v-model="carModuleNoData" placeholder="输入配置代码" style="width:120!important"></el-input>
				</el-col>
				<el-col :span="1">
					<el-button type="primary" size="small" v-on:click='carSeriesQuery'>查询</el-button>
				</el-col>
				<el-col :span="8" style="text-align: right;margin:10px 0 4px -15px;float: right;">
					<el-button type="primary" size="small" v-on:click='carConfigureAdd' v-if="btnGroup.add">新增</el-button>
					<el-button type="primary" size="small" v-on:click='editCarConfigure' v-if="btnGroup.edit">编辑</el-button>
					<el-button type="primary" size="small" v-on:click='startCarConfigure' v-if="btnGroup.start">启用</el-button>
					<el-button type="primary" size="small" v-on:click='stopCarConfigure' v-if="btnGroup.stop">停用</el-button>
				</el-col>
			</el-col>
		</el-row>
		<el-row :gutter="24">
			<!-- 参数树 -->
			<el-col :span="6" style="padding-right: 5px!important;padding-left: 15px!important">
				<el-tree :data="paramTreeData" :filter-node-method="filterNode" :highlight-current=true :props="defaultProps" accordion @node-click="handleNodeClick" :auto-expand-parent=false ref="dictTree" node-key="id"></el-tree>
			</el-col>
			<el-col :span="18">
				<el-row v-if="carType=='0'">
					<el-table :data="carSeries.dataList" stripe border style="width:100%" height="460" @row-click='carSeriesRowClick' highlight-current-row @selection-change="handleSelectionChange">
						<el-table-column type="selection" width="60" fixed>
						</el-table-column>
						<el-table-column prop="brandCode" label="品牌" width="100" :formatter="deptCov">
						</el-table-column>
						<el-table-column prop="carSeriesCode" label="车系编码" width="200">
						</el-table-column>
						<el-table-column prop="carSeriesName" label="车系名称" width="200">
						</el-table-column>
						<el-table-column prop="carModuleNo" label="车辆型号代码" width="200">
						</el-table-column>
						<el-table-column prop="carModule" label="车辆型号" width="200">
						</el-table-column>
						<el-table-column prop="labelNumber" label="厂牌代码" width="200">
						</el-table-column>
						<el-table-column prop="saleStatus" label="是否在售" :formatter="saleStatusCov" width="100" >
						</el-table-column>
						<el-table-column prop="carSeriesLevel" label="车辆等级" :formatter="levelCov" width="120">
						</el-table-column>
						<el-table-column prop="resStatus" label="状态" :formatter="statusCov" width="100">
						</el-table-column>
					</el-table>
					<el-pagination small v-if="carType" @size-change="handleGroupSizeChange" @current-change="handleGroupCurrentChange" :current-page="groupCurentPage" :page-sizes="page.pageSizes" :page-size="page.pageSize" layout=" total,prev, pager, next" :total="carSeries.total">
					</el-pagination>
				</el-row>
				<el-row :gutter="24"  v-if="carType=='1'">
					<el-col :span="24">
						<el-table :data="carModel.dataList" stripe border style="width:100%" height="460" @selection-change="handleSelectionChange2">
							<el-table-column type="selection" width="60" fixed>
							</el-table-column>
							<el-table-column prop="modelName" label="车型中文名称">
							</el-table-column>
							<el-table-column prop="modelCode" label="车型英文代码">
							</el-table-column>
							<el-table-column prop="vinCode" label="vin号识配码">
							</el-table-column>
							<el-table-column prop="displacement" label="排量">
							</el-table-column>
							<el-table-column prop="seats" label="座位数">
							</el-table-column>
							<el-table-column prop="resStatus" label="状态" :formatter="statusCov" width="120">
							</el-table-column>
						</el-table>
						<el-pagination small @size-change="handleDictSizeChange" @current-change="handleDictCurrentChange" :current-page="dictCurentPage" :page-sizes="page.pageSizes" :page-size="page.pageSize" layout=" total,prev, pager, next" :total="carModel.total">
						</el-pagination>
					</el-col>
				</el-row>
				<el-row :gutter="24"   v-if="carType=='2'">
					<el-col :span="24">
						<el-table :data="carConfigure.dataList" stripe border height="460" @selection-change="handleSelectionChange2">
							<el-table-column type="selection" width="60" fixed>
							</el-table-column>
							<el-table-column prop="configureCode" label="配置代码" >
							</el-table-column>
							<el-table-column prop="configureName" label="配置名称"  >
							</el-table-column>
							<el-table-column prop="vinCode" label="vin号识配码"  >
							</el-table-column>
							<el-table-column prop="certificateCode" label="合格证代码" >
							</el-table-column>
							<el-table-column prop="appearance" label="外观" >
							</el-table-column>
							<el-table-column prop="interior" label="内饰" >
							</el-table-column>
							<el-table-column prop="carPurchasingPrice" label="车辆采购价" >
							</el-table-column>
							<el-table-column prop="carSalePrice" label="销售价格" >
							</el-table-column>
							<el-table-column prop="resStatus" label="状态" :formatter="statusCov" width="120">
							</el-table-column>
						</el-table>
						<el-pagination small @size-change="handleDictSizeChange" @current-change="handleDictCurrentChange" :current-page="dictCurentPage" :page-sizes="page.pageSizes" :page-size="page.pageSize" layout=" total,prev, pager, next" :total="carConfigure.total">
						</el-pagination>
					</el-col>
				</el-row>
			</el-col>
		</el-row>
		</el-row>
		<!--车系表单-->
		<el-dialog title="车系" v-model="carSeriesShow">
			<el-form :model="carSeriesFormData" ref="carSeriesForm" :rules="dictRule" label-width="150px">
				<el-col :span="12">
					<el-form-item label="车辆品牌" prop="brandCode" required>
						<el-select size="small" v-model="carSeriesFormData.brandCode" placeholder="请选择品牌">
							<el-option v-for="item in brandComboData" :label="item.label" :value="item.value"></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="车系编码" prop="carSeriesCode" required>
						<el-input size="small" v-model="carSeriesFormData.carSeriesCode"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="车系名称" prop="carSeriesName" required>
						<el-input size="small" v-model="carSeriesFormData.carSeriesName">
						</el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="厂牌代码" prop="labelNumber" >
						<el-input size="small" v-model="carSeriesFormData.labelNumber">
						</el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="是否在销" prop="saleStatus" required>
						<el-select size="small" v-model="carSeriesFormData.saleStatus" placeholder="请选择是否在销	">
							<el-option v-for="item in isSaleCombo" :label="item.label" :value="item.value"></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="车辆等级" prop="carSeriesLevel" required>
						<el-select size="small" v-model="carSeriesFormData.carSeriesLevel" placeholder="请选择车辆等级">
							<el-option v-for="item in levelComboData" :label="item.label" :value="item.value"></el-option>
						</el-select>
					</el-form-item>
				</el-col>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click="carSeriesShow = false">取 消</el-button>
				<el-button type="primary" @click="saveCarSeries">提交</el-button>
			</div>
		</el-dialog>
		<!--车型表单 -->
		<el-dialog title="车型" v-model="carModelFormShow">
			<el-form :model="carModelFormData" ref="dictForm" :rules="carModelRule" label-width="150px">
				<el-col :span="24">
					<el-form-item label="车系名称" prop="dataValue" required>
						<el-input size="small" v-model="dataValue" readonly></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="车型中文名称" prop="modelName" required>
						<el-input size="small" v-model="carModelFormData.modelName"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="vin号识配码" prop="vinCode" required>
						<el-input size="small" v-model="carModelFormData.vinCode"></el-input>
					</el-form-item>
				</el-col>

				<el-col :span="24">
					<el-form-item label="车型英文代码" prop="modelCode" required>
						<el-input size="small" v-model="carModelFormData.modelCode"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="车型排量" prop="displacement" required>
						<el-input size="small" placeholder="" v-model="carModelFormData.displacement">
						</el-input>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="座位数" prop="seats" required>
						<el-input size="small" placeholder="" v-model="carModelFormData.seats">
						</el-input>
					</el-form-item>
				</el-col>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click="carModelFormShow = false">取 消</el-button>
				<el-button type="primary" @click="saveCarModle">提交</el-button>
			</div>
		</el-dialog>
		<!--配置表单 -->
		<el-dialog title="配置" v-model="carConfigureFormShow">
			<el-form :model="carConfigureFormData" ref="dictForm" :rules="carConfigureRule" label-width="150px">
				<el-col :span="12">
					<el-form-item label="配置代码" prop="configureCode" required>
						<el-input size="small" v-model="carConfigureFormData.configureCode"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="配置名称" prop="configureName" required>
						<el-input size="small" v-model="carConfigureFormData.configureName"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="vin号识配码" prop="vinCode" required>
						<el-input size="small" v-model="carConfigureFormData.vinCode"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="合格证代码" prop="certificateCode" required>
						<el-input size="small" v-model="carConfigureFormData.certificateCode"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="外观" prop="appearance">
						<el-input size="small" v-model="carConfigureFormData.appearance"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="内饰" prop="interior">
						<el-input size="small" placeholder="" v-model="carConfigureFormData.interior">
						</el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="车辆采购价" prop="carPurchasingPrice" required>
						<el-input size="small" placeholder="" v-model="carConfigureFormData.carPurchasingPrice">
						</el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="车辆销售价" prop="carSalePrice" required>
						<el-input size="small" placeholder="" v-model="carConfigureFormData.carSalePrice">
						</el-input>
					</el-form-item>
				</el-col>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click="carConfigureFormShow = false">取 消</el-button>
				<el-button type="primary" @click="saveCarConfigure">提交</el-button>
			</div>
		</el-dialog>
	</div>
</template>
<script>
	import moment from 'moment'
	export default {
		data: function() {
			return {
				//是否显示全部车系
				allSeries: '1',
				
				//左侧数数据
				paramTreeData: [],
				//树型数据配置
				defaultProps: {
					children: 'child',
					label: 'label'
				},
				//字典树的过滤条件
				dictTreeSearchValue: '',
				
			
				//选中的节点的lable
				datalabel: '',
				//选中的节点的id
				dataValue: "",
				//品牌还是车型
				carType: '1',

				btnGroup: {},
				//分页设置
				page: this.page,
				//车系数据
				carSeries: {
					total: 0,
					dataList: []
				},
				//品牌编码
				brandCode: '',
				//车系查询条件
				groupValue: '',
				//车辆型号查询条件
				carModuleData: '',
				//车辆型号查询条件
				carModuleNoData: '',
				//车型数据
				carModel: {
					total: 0,
					dataList: []
				},
				//车辆配置
				carConfigure: {
					total: 0,
					dataList: []
				},
				//字典转换值
				brandConvertData: {},
				//等级转换
				levelConvertData: {},
				//类型
				type: '',

				//当前车系页
				groupCurentPage: 1,
				//当前字典页
				dictCurentPage: 1,
				//品牌下拉
				brandComboData: [],
				//车辆等级下拉
				levelComboData: [],
				//是否在销的下拉
				isSaleCombo: [{
					label: "是",
					value: "1"
				}, {
					label: "否",
					value: "0"
				}],
				//选中的车系编号
				carSeriesCode: '',
				//选中的车系名称
				carSeriesName: '',
				// 字典车系表单
				carSeriesShow: false,
				
				
				emptyData: {
					id: null,
					brandCode: '',
					carSeriesCode: '',
					carSeriesName: '',
					carModuleNo: '',
					carModule: '',
					carTypeName: '',
					carTypeCode: '',
					carSeriesLevel: '',
					resStatus: '1',
					carSet: '',
					carColor: '',
					type: '',
					createTime: 0,
					createUser: '',
					updateTime: 0,
					updateUser: '',
					pCarSeries: '',
					showLevel: '',
					saleStatus:'',
					labelNumber:'',
				},
				//字典车系数据
				carSeriesFormData: {
					id: null,
					brandCode: '',
					carSeriesCode: '',
					carSeriesName: '',
					carModuleNo: '',
					carModule: '',
					carTypeName: '',
					carTypeCode: '',
					carSeriesLevel: '',
					resStatus: '1',
					carSet: '',
					carColor: '',
					type: '',
					createTime: 0,
					createUser: '',
					updateTime: 0,
					updateUser: '',
					pCarSeries: '',
					showLevel: '',
					saleStatus:'',
					labelNumber:'',
				},
				
				
				modelEmptyData: {
					id: null,
					brandCode: '',
					carSeriesCode: '',
					carSeriesName: '',
					carModuleNo: '',
					carModule: '',
					carTypeName: '',
					carTypeCode: '',
					carSeriesLevel: '',
					resStatus: '1',
					carSet: '',
					carColor: '',
					type: '',
					createTime: 0,
					createUser: '',
					updateTime: 0,
					updateUser: '',
					pCarSeries: '',
					showLevel: '',
				},
				
				//字典车型初始数据
				carModelEmptyData: {
					id: null,
					seriesId: '',
					modelName: '',
					modelCode: '',
					displacement: '',
					seats: '',
					brandCode: '',
					resStatus: '',
					vinCode: '',
					showLevel: '',
				},
				//字典车型数据
				carModelFormData: {
					id: null,
					seriesId: '',
					modelName: '',
					modelCode: '',
					displacement: '',
					seats: '',
					brandCode: '',
					resStatus: '',
					vinCode: '',
					showLevel: '',
				},
				//配置的from
				carConfigureFormData: {
					id: null,
					configureName: "",
					configureCode: "",
					certificateCode: "",
					appearance: "",
					interior: "",
					carPurchasingPrice: "",
					carSalePrice: "",
					brandCode: "",
					resStatus: "",
					modelId: "",
					vinCode: '',
					showLevel: '',
				},
				//配置的初始数据
				carConfigureEmptyData: {
					id: null,
					configureName: "",
					configureCode: "",
					certificateCode: "",
					appearance: "",
					interior: "",
					carPurchasingPrice: "",
					carSalePrice: "",
					brandCode: "",
					resStatus: "",
					modelId: "",
					vinCode: '',
					showLevel: '',
				},
				//车型表单
				carModelFormShow: false,
				//配置表单
				carConfigureFormShow: false,
				//				//字典数据
				//				carSeriesFormData: {
				//					"id": null,
				//					"createTime": 0,
				//					"createUser": "",
				//					"updateTime": 0,
				//					"updateUser": '',
				//					"status": "",
				//					"tDisp": "",
				//					"tDispOrder": "",
				//					"tGroup": "",
				//					"tGroupName": "",
				//					"tType": "",
				//					"tValue": ""
				//				},
				//系统车系字典
				groupType: [],
				//业务系统字典
				moduleCombo: [],
				moduleCon: {},
				carModelRule: {
					//					carTypeName: [{
					//						required: true,
					//						message: '请输入车型中文名称',
					//						trigger: 'blur'
					//					}],
					//					carTypeCode: [{
					//						required: true,
					//						message: '请输入车型中文名称',
					//						trigger: 'blur'
					//					}],
					//					carSet: [{
					//						required: true,
					//						message: '请输入车辆配置',
					//						trigger: 'blur'
					//					}],
					//					carColor: [{
					//						required: true,
					//						message: '请输入车辆颜色',
					//						trigger: 'blur'
					//					}],
				},

				carConfigureRule: {

//					configureCode: [{
//						required: true,
//						message: '请输入配置编码',
//						trigger: 'blur'
//					}],
//
//					configureName: [{
//						required: true,
//						message: '请输入配置名称',
//						trigger: 'blur'
//					}],
//					certificateCode: [{
//						required: true,
//						message: '请输入合格证号',
//						trigger: 'blur'
//					}],
//					carPurchasingPrice: [{
//						required: true,
//						message: '请输入采购价格',
//						trigger: 'blur'
//					}],
//					carSalePrice: [{
//						required: true,
//						message: '请输入销售价格',
//						trigger: 'blur'
//					}],

				},

				//校验规则
				dictRule: {
					brandCode: [{
						required: true,
						message: '请选择品牌',
						trigger: 'change'
					}],
					carSeriesCode: [{
						required: true,
						message: '请输入车系编码',
						trigger: 'blur'
					}],
					carSeriesName: [{
						required: true,
						message: '请输入车系名称',
						trigger: 'blur'
					}],
					carModuleNo: [{
						required: true,
						message: '车辆型号代码',
						trigger: 'blur'
					}],
					carModule: [{
						required: true,
						message: '请输入车辆型号',
						trigger: 'blur'
					}],
					carTypeName: [{
						required: true,
						message: '请输入车型中文名称',
						trigger: 'blur'
					}],
					carTypeCode: [{
						required: true,
						message: '请输入车型中文名称',
						trigger: 'blur'
					}],
					carSet: [{
						required: true,
						message: '请输入车辆配置',
						trigger: 'change'
					}],
					
					multipleSelection: [],
					multipleSelection2: [],

				}
			}
		},
		computed: {

		},
		methods: {
			//点击资源树节点
			handleNodeClick(data) {
				debugger;
				this.$data.carType = data.type;
				this.$data.datalabel = data.value;
				this.$data.dataValue = data.label;
				if(data.type == '0') {
					this.carSeriesQuery();
				} else if(data.type == '1') {
					this.carModelQuery();
				} else if(data.type == '2') {
					this.carConfigureQuery();
				}
			},
			
			//是否在售状态转换
			saleStatusCov: function(row, column) {
				return row.saleStatus == "1" ? '在售' : '已停售';
			},
			
			//资源过滤
			filterNode: function(value, data, node) {
				if(!value) return true;
				return data.label.indexOf(value) !== -1;
			},
			//查询树节点
			searchTree: function() {
				if(this.$data.dictTreeSearchValue == "") {
					this.$message("请输入查询条件");
					this.queryParamTree();
					return;
				}
				this.$refs.dictTree.filter(this.$data.dictTreeSearchValue);
			},
			//查询参数树
			queryParamTree: function() {
				//获取资源树
				debugger;
				this.$http.get(this.API_ROOT + '/base/car/tree', {
				
					params: {
						showLevel: this.$data.carSeriesFormData.showLevel,
						allSeries: this.$data.allSeries,										
					}
				}).then((response) => {
					this.$data.paramTreeData = response.data;
					//this.carSeriesQuery();
				}, (response) => {});
			},
			
			//选择框
			handleSelectionChange: function(val) {
				debugger;
				this.$data.multipleSelection = val;
				if(this.$data.multipleSelection.length > 1)
					this.$message.error("请选择一条数据！");
			},
			//选择框
			handleSelectionChange2: function(val) {
				debugger;
				this.$data.multipleSelection2 = val;
				if(this.$data.multipleSelection2.length > 1)
					this.$message.error("请选择一条数据！");
			},
			//车系行被点击
			carSeriesRowClick: function(row) {
				this.$data.carSeriesCode = row.carSeriesCode;
				this.$data.carSeriesName = row.carSeriesName;
				this.carModelQuery();
			},
			//车系查询
			carSeriesQuery: function() {
				debugger;
				this.$http({
					method: 'GET',
					url: this.API_ROOT + '/base/car/page',
					params: {
						type: this.$data.carType,
						bCode: this.$data.datalabel,
						start: this.$data.groupCurentPage,
						limit: this.$data.page.pageSize,
						carModule: this.$data.carModuleData,
						carModuleNo: this.$data.carModuleNoData,
						allSeries:this.$data.allSeries,
					}
				}).then(function(resp) {
					resp.data.total = parseInt(resp.data.total);
					// es5写法
					this.$data.carSeries = resp.data;
					if(this.$data.carSeries.dataList.length > 0) {
						debugger;
						this.$data.carSeriesCode = this.$data.carSeries.dataList[0].carSeriesCode;
						this.$data.carSeriesName = this.$data.carSeries.dataList[0].carSeriesName;
					} else {
						this.$data.carSeriesCode = '';
					}
					this.carModelQuery();
				}, function(error) {
					// error
				})
			},
			//车系增加
			carSeriesAdd: function() {
				//重新清空数据
				debugger;
				this.$data.carSeriesFormData = Object.assign(this.$data.carSeriesFormData, this.$data.emptyData);
				this.$data.carSeriesFormData.brandCode = this.$data.datalabel;
				this.$data.carSeriesShow = true;
			},
			//字典车系，分页大小切换
			handleGroupSizeChange: function() {

			},
			//字典车系,当前页切换
			handleGroupCurrentChange: function(currentPage) {
				this.$data.groupCurentPage = currentPage;
				this.$data.carSeriesCode = '';
				this.carSeriesQuery();
			},
			//启用车系
			startCarSeries: function() {
				if(this.$data.multipleSelection.length == 1) {
					var resRoleData = this.$data.multipleSelection[0];
					//this.$data.carSeriesCode = data.gCode;
					this.$http({
						method: 'POST',
						url: this.API_ROOT + '/base/car/start',
						params: {
							id: resRoleData.id,
						}
					}).then(function(resp) {
						this.carSeriesQuery();
					}, function(error) {
						// error
					})
				} else {
					this.$message.error("请选择一条数据");
				}
			},
			//停用车系
			stopCarSeries: function() {
				if(this.$data.multipleSelection.length == 1) {

					var resRoleData = this.$data.multipleSelection[0];

					//this.$data.carSeriesCode = data.gCode;

					this.$http({
						method: 'POST',
						url: this.API_ROOT + '/base/car/stop',
						params: {
							id: resRoleData.id,
						}
					}).then(function(resp) {
						this.carSeriesQuery();
					}, function(error) {
						// error
					})
				} else {
					this.$message.error("请选择一条数据");
				}

			},
			//编辑车系
			editCarSeries: function() {
				if(this.$data.multipleSelection.length == 1) {

					var resRoleData = this.$data.multipleSelection[0];
					//判断车系类型

					//				//判断是否可编辑
					//				if(groupData.gType == 0 || groupData.gType == '0') {
					//					this.$message("系统车系不允许编辑!");
					//					return;
					//				}
					this.$http.get(this.API_ROOT + '/base/car/info', {
						params: {
							id: resRoleData.id
						}
					}).then((response) => {
						// success callback
						this.$data.carSeriesFormData = Object.assign(this.$data.carSeriesFormData, response.data.data);
					}, (response) => {
						// error callback
					});
					this.$data.carSeriesShow = true;
				} else {
					this.$message.error("请选择一条数据");
				}

			},
			//保存车系
			saveCarSeries: function() {
				this.$refs.carSeriesForm.validate(function(valid, $event) {
					//this.$data.carSeriesFormData.id=0;
					this.$data.carSeriesFormData.type = 0;
					//debugger;

					// 验证通过
					if(valid) {
						debugger;
						this.$http.post(this.API_ROOT + '/base/car/save', this.$data.carSeriesFormData)
							.then(resp => {
								debugger;
								if(resp.data.success) {
									debugger;
									//this.$message(resp.data.msg);
									this.carSeriesQuery();
									this.$data.carSeriesShow = false;
									this.queryParamTree();

								} else {
									this.$message.error(resp.data.msg);
								}
							}, resp => {

							});
					} else {
						return false
					}
				}.bind(this))
			},
			//车型查询
			carModelQuery: function() {
				this.$http({
					method: 'GET',
					url: this.API_ROOT + '/base/carModel/page',
					params: {
						seriesId: this.$data.datalabel,
						start: this.$data.dictCurentPage,
						limit: this.$data.page.pageSize,
						modelCode: this.$data.carModuleNoData,
					}
				}).then(function(resp) {
					resp.data.total = parseInt(resp.data.total);
					debugger;
					this.$data.carModel = resp.data;
				}, function(error) {
					// error
				})

			},
			//配置查询
			carConfigureQuery: function() {
				debugger;
				this.$http({
					method: 'GET',
					url: this.API_ROOT + '/base/carConfigure/page',
					params: {
						modelId: this.$data.datalabel,
						start: this.$data.dictCurentPage,
						limit: this.$data.page.pageSize,
						configureCode: this.$data.carModuleNoData,
					}
				}).then(function(resp) {
					resp.data.total = parseInt(resp.data.total);
					debugger;
					this.$data.carConfigure = resp.data;
				}, function(error) {
					// error
				})

			},
			//车型增加
			carModelAdd: function() {
				debugger;
				this.$data.carModelEmptyData.seriesId = this.$data.datalabel;
				this.$data.carModelFormData = Object.assign(this.$data.carModelFormData, this.$data.carModelEmptyData);
				this.$data.carModelFormShow = true;
			},
			////配置增加
			carConfigureAdd: function() {
				debugger;
				this.$data.carConfigureEmptyData.modelId = this.$data.datalabel;
				this.$data.carConfigureFormData = Object.assign(this.$data.carConfigureFormData, this.$data.carConfigureEmptyData);
				this.$data.carConfigureFormShow = true;
			},
			//字典，分页大小切换
			handleDictSizeChange: function() {

			},
			//字典,当前页切换
			handleDictCurrentChange: function(currentPage) {
				this.$data.dictCurentPage = currentPage;
				this.carModelQuery();
			},
			//启用车型
			startCarModel: function() {
				if(this.$data.multipleSelection2.length == 1) {

					var resRoleData = this.$data.multipleSelection2[0];

					this.$http({
						method: 'POST',
						url: this.API_ROOT + '/base/carModel/start',
						params: {
							id: resRoleData.id,
						}
					}).then(function(resp) {
						this.$message(resp.data.msg);
						this.carModelQuery();
					}, function(error) {
						// error
					})

				} else {
					this.$message.error("请选择一条数据");
				}

			},
			//启用配置
			startCarConfigure: function() {
				if(this.$data.multipleSelection2.length == 1) {
					var resRoleData = this.$data.multipleSelection2[0];
					this.$http({
						method: 'POST',
						url: this.API_ROOT + '/base/carConfigure/start',
						params: {
							id: resRoleData.id,
						}
					}).then(function(resp) {
						this.$message(resp.data.msg);
						this.carConfigureQuery();
					}, function(error) {
						// error
					})
				} else {
					this.$message.error("请选择一条数据");
				}

			},
			//停用车型
			stopCarModel: function() {
				if(this.$data.multipleSelection2.length == 1) {

					var resRoleData = this.$data.multipleSelection2[0];
					debugger;
					this.$http({
						method: 'POST',
						url: this.API_ROOT + '/base/carModel/stop',
						params: {
							id: resRoleData.id,
						}
					}).then(function(resp) {
						this.$message(resp.data.msg);
						this.carModelQuery();
					}, function(error) {
						// error
					})
				} else {
					this.$message.error("请选择一条数据");
				}
			},
			//停用配置
			stopCarConfigure: function() {
				if(this.$data.multipleSelection2.length == 1) {

					var resRoleData = this.$data.multipleSelection2[0];
					debugger;
					this.$http({
						method: 'POST',
						url: this.API_ROOT + '/base/carConfigure/stop',
						params: {
							id: resRoleData.id,
						}
					}).then(function(resp) {
						this.$message(resp.data.msg);
						this.carConfigureQuery();
					}, function(error) {
						// error
					})
				} else {
					this.$message.error("请选择一条数据");
				}
			},
			//编辑车型
			editCarModel: function() {
				//判断车系类型
				if(this.$data.multipleSelection2.length == 1) {
					var resRoleData = this.$data.multipleSelection2[0];
					this.$http.get(this.API_ROOT + '/base/carModel/info', {
						params: {
							id: resRoleData.id
						}
					}).then((response) => {
						// success callback
						//this.$data.carModelEmptyData.seriesId = this.$data.datalabel;
						//this.$data.carModelFormData = Object.assign(this.$data.carModelFormData, this.$data.carModelEmptyData);
						//this.$data.carModelFormShow = true;
						this.$data.carModelFormData = Object.assign(this.$data.carModelFormData, response.data.data);
					}, (response) => {
						// error callback
					});
					this.$data.carModelFormShow = true;
				} else {
					this.$message.error("请选择一条数据");
				}
			},
			//编辑配置
			editCarConfigure: function() {
				//判断车系类型
				if(this.$data.multipleSelection2.length == 1) {
					var resRoleData = this.$data.multipleSelection2[0];
					this.$http.get(this.API_ROOT + '/base/carConfigure/info', {
						params: {
							id: resRoleData.id
						}
					}).then((response) => {
						// success callback
						//this.$data.carModelEmptyData.seriesId = this.$data.datalabel;
						//this.$data.carModelFormData = Object.assign(this.$data.carModelFormData, this.$data.carModelEmptyData);
						//this.$data.carModelFormShow = true;
						this.$data.carConfigureFormData = Object.assign(this.$data.carConfigureFormData, response.data.data);
					}, (response) => {
						// error callback
					});
					this.$data.carConfigureFormShow = true;
				} else {
					this.$message.error("请选择一条数据");
				}
			},
			//保存车型信息
			saveCarModle: function() {
				this.$refs.dictForm.validate(function(valid, $event) {
					debugger;
					if(valid) {
						this.$http.post(this.API_ROOT + '/base/carModel/save', this.$data.carModelFormData)
							.then(resp => {
								if(resp.data.success) {
									this.$message(resp.data.msg);
									this.$data.carModelFormShow = false;
									this.queryParamTree();
									this.carModelQuery();
								} else {
									this.$message.error(resp.data.msg);
								}
							}, resp => {});
					} else {
						return false
					}
				}.bind(this))
			},
			//保存配置信息Configure
			saveCarConfigure: function() {
				this.$refs.dictForm.validate(function(valid, $event) {
					debugger;
					if(valid) {
						this.$http.post(this.API_ROOT + '/base/carConfigure/save', this.$data.carConfigureFormData)
							.then(resp => {
								if(resp.data.success) {
									this.$message(resp.data.msg);
									this.carConfigureQuery();
									this.$data.carConfigureFormShow = false;
									this.queryParamTree();
								} else {
									this.$message.error(resp.data.msg);
								}
							}, resp => {});
					} else {
						return false
					}
				}.bind(this))
			},
			//状态转换
			statusCov: function(row, column) {
				return row.resStatus == "1" ? '已启用' : '已停用';
			},
			//品牌转换
			deptCov: function(row, column) {
				return this.$data.brandConvertData[row.brandCode];
			},
			//等级转换
			levelCov: function(row, column) {
				return this.$data.levelConvertData[row.carSeriesLevel];
			},
			//品牌转换
			queryDeptCovert: function() {
				this.$http.get(this.API_ROOT + '/base/brand/convert', {
					params: {}
				}).then((response) => {
					this.$data.brandConvertData = response.data;
				}, (response) => {});
			},
			//等级转换
			levelCovert: function() {
				this.$http.get(this.API_ROOT + '/base/dict/convert', {
					params: {
						group: "0501"
					}
				}).then((response) => {
					this.$data.levelConvertData = response.data;
				}, (response) => {});
			},
		},
		//表单创建时执行
		created: function() {
			this.$data.carSeriesCode = '';
			//品牌转换
			this.queryDeptCovert();
			this.levelCovert();
			//查询参数树
			this.queryParamTree();
			//获取品牌厂下拉
			this.$http.get(this.API_ROOT + '/base/brand/combo', {
				params: {}
			}).then((response) => {
				this.$data.brandComboData = response.data;
			}, (response) => {});
			//获取品牌厂下拉
			this.$http.get(this.API_ROOT + '/base/dict/combo', {
				params: {
					group: "0501"
				}
			}).then((response) => {
				this.$data.levelComboData = response.data;
			}, (response) => {});
			//按钮权限
			this.$http({
				method: 'GET',
				url: this.API_ROOT + '/rbac/login/btn', //url 输出 按照车牌号的 车牌号
				params: { //发送的参数
					resPath: "base/CarSeries", ////查询条件 按照输入的车牌号
				}
			}).then(function(resp) {
				debugger;
				var btnData = resp.data.dataList;
				var temp = {};
				for(var i = 0; i < btnData.length; i++) {
					var btnName = btnData[i].btnName;
					temp[btnName] = btnName;
				}
				Object.assign(this.$data.btnGroup, temp);
			}, function(error) {
				// error
			})
		}
	}
</script>
<style>
	.el-table .info-row {
		height: 15px !important;
	}
	
	.item {
		width: 30px;
	}
	
	.el-dropdown .el-button-group,
	.el-table .el-tooltip,
	.el-table .el-tooltip__rel {
		display: inline;
	}
</style>